<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateParkProtectsTable extends Migration
{
    /**
     * Run the migrations.
     *园林养护内容预设表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('park_protects', function (Blueprint $table) {
            //字段定义
            $table->increments('id');
            $table->integer('landscaping_id')->unsigned()->comment('园林ID');
            $table->integer('protect_month')->unsigned()->comment('作业月份');
            $table->text('protect_content')->comment('作业内容');
            $table->string('protect_type',80)->comment('植被种类');
            $table->integer('protect_number')->unsigned()->comment('植物数量');
            $table->string('protect_units')->comment('单位');
            $table->timestamp('begin_time')->nullable()->comment('作业开始时间');
            $table->timestamp('end_time')->nullable()->comment('作业结束时间');
            $table->string('protect_job',20)->comment('作业种类');
            $table->integer('protect_principal_id')->unsigned()->comment('负责人id')->nullable();
            $table->foreign('protect_principal_id')->references('id')->on('employees')->onDelete('set null');
            $table->string('protect_remark',20)->comment('完成度')->nullable(true);
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('park_protects');
    }
}
